home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 701-725 / 718 / settime / settime.asm < prev    next >
Assembly Source File  |  1995-03-18  |  11KB  |  345 lines

  1. *******************************************************************************
  2. *                                                                             *
  3. *                       Settime V0.9 © 1991 by Acki                           *
  4. *                                                                             *
  5. * This useful utility takes the time from the internal hardware clock and     *
  6. * sets it as the System-time. No Workbench-usage !!. The clock is supposed    *
  7. * to be at $dc0000; no clock in this area and running settime will result     *
  8. * in an invalid System-time. I wrote this programm because I wanted a really  *
  9. * fast and small timeset-utility different from Commodores Setclock which     *
  10. * always takes such a long loading time.                                      *
  11. * Use it at your own risk !!! I didn't test it extensively, so there still    *
  12. * might be bugs. If you figure out one, please let me know !!!. It worked     *
  13. * quite smoothly from  29-aug to 30-sep.                                      *
  14. *                                                                             *
  15. * This directory contains the executable and the same thing as a *bootblock*! *
  16. * Settime.bbl is the custom-bootblock as it is used by BBChampion and many    *
  17. * other utilities; Settime.zv is the same thing in Zerovirus-Format (I used   *
  18. * the Version on Fish 412).                                                   *
  19. * Each Bootblock is complete (Checksum,Bootcode etc.), simply load it with    *
  20. * your favourite Virushunter or Bootblocktool (Zerovirus, BootBlockChampion   *
  21. * etc.) and save it on your startup-disk.                                     *
  22. * Whenever a disk containing this bootblock is booted up, the screen will     *
  23. * turn black and show green stripes for a moment to indicate that you         *
  24. * have installed Settime.                                                     *
  25. *                                                                             *
  26. *                                                                             *
  27. * If you reassemble the file like it is, you'll get the Cli-Version.          *
  28. * To get a bootblock, simply remove the ';' at each line and act as if you    *
  29. * wanted to get a normal, runable programm. Then take BootBlockChampion III,  *
  30. * select 'Load Bootblock' ,choose 'Bootblock Code' and load your              *
  31. * 'executable'. Select 'Ok' and the Bootblock will be installed on your Disk. *
  32. *                                                                             *
  33. * Are you interested in writing Custom-Bootblocks yourself ?                  *
  34. * On Fish 242 there is a detailed description how it works and what you       *
  35. * should take care of !                                                       *
  36. *                                                                             *
  37. * This Programm is FREEWARE. Use it at your own risk etc. !!!                 *
  38. * If you want to release it with your Anti-virus-utility or BootblockTool     *
  39. * as Custom-Bootblock, please let me know !!!                                 *
  40. *                                                                             *
  41. * All this stuff was written using the Devpac V2.14 Assembler, Kickstart 1.2  *
  42. *                                                                             *
  43. *                           Thanks in advance for your comments !             *
  44. *                                                                             *
  45. *                                     Andreas Ackermann                       *
  46. *                                     Lorenz-Summa-Str. 10                    *
  47. *                                     W-8679 Oberkotzau                       *
  48. *                                     Germany                                 *
  49. *                                     Phone: 09286/6399                       *
  50. *                                                                             *
  51. *                                     03-Oct-91 10:24:14                      *                  *
  52. *                                                                             *
  53. *******************************************************************************
  54.  
  55.             rsreset
  56. ln          rs.b    0
  57. ln_succ     rs.l    1
  58. ln_pred     rs.l    1
  59. ln_type     rs.b    1
  60. ln_pri      rs.b    1
  61. ln_name     rs.l    1
  62. ln_size     rs.l    0
  63.  
  64. nt_msgport  equ     4
  65. nt_message  equ     5
  66.             rsreset
  67. mp          rs.b    ln_size
  68. mp_flags    rs.b    1
  69. mp_sigbit   rs.b    1
  70. mp_sigtask  rs.l    1
  71. mp_msglist  rs.b    14
  72.             rsreset
  73. mn          rs.b    ln_size
  74. mn_replyport    rs.l    1
  75. mn_length       rs.w    1
  76. mn_size         rs.w    0
  77.             rsreset
  78.  
  79. iostdrequest    rs.l    0
  80. io_message      rs.b    mn_size
  81. io_device       rs.l    1
  82. io_unit         rs.l    1
  83. io_command      rs.w    1
  84. io_flags        rs.b    1
  85. io_error        rs.b    1
  86. io_size         rs.l    0
  87. io_actual       rs.l    1
  88. io_length       rs.l    1
  89. io_data         rs.l    1
  90. io_offest       rs.l    1
  91. iostd_size      rs.l    0
  92.  
  93.             rsreset
  94.  
  95. td          rs.l    0
  96. td_io       rs.b    io_size
  97. tv_secs     rs.l    1
  98. tv_micro    rs.l    1
  99.  
  100.         include "exec/exec_lib.i"
  101.  
  102. ;anfang  move.l  4.w,a6           ;standard routine at the beginning
  103. ;        lea.l   dosname(pc),a1   ;of each bootblock
  104. ;        jsr     -$60(A6)
  105. ;        move.l  d0,a0
  106. ;        move.l  $16(a0),a0
  107. ;        bsr     _main
  108. ;        moveq   #0,d0
  109. ;        rts
  110.  
  111. ;dosname dc.b    'dos.library',0
  112. ;        even
  113.  
  114. _main
  115.         movem.l d0-7/a0-6,-(sp)
  116. ;        moveq   #$ff,d0           ; that's all to get the gfx
  117. ;alert   add.w   #$111,$dff180     ; when we boot up !
  118. ;        dbf     d0,alert
  119.  
  120.         moveq   #1,d2
  121.         moveq   #0,d1
  122.         lea     devname(pc),a0
  123.         moveq   #60,d0
  124.         bsr     open_a_device     ;open timer.device
  125.         move.l  d0,d7
  126.         move.l  d0,a1
  127.  
  128.         move.w  #11,io_command(a1)
  129.                                   ;command: setsystime
  130.         move.l  #$dc0000,a0       ;format: number of seconds since
  131.         moveq   #$28,d1           ;1-jan-78
  132.         bsr     getdez            ;number of years
  133.  
  134.         move.w  d0,d3
  135.  
  136. 4$
  137.         sub.w   #78,d0
  138.         move.w  d0,d1
  139.         addq    #1,d1
  140.         lsr.w   #2,d1
  141.  
  142. 2$      add.l   #60*60*24,d2
  143.         dbf     d1,2$
  144.         sub.l   #60*60*24,d2
  145.  
  146. 1$      add.l   #$1e13380,d2
  147.         dbf     d0,1$
  148.         sub.l   #$1e13380,d2
  149.  
  150.         moveq   #$20,d1
  151.         bsr     getdez           ;actual month
  152.  
  153.         lea     monthtable(pc),a1
  154.         move.l  #60*60*24*28,8(a1)
  155.  
  156.         btst.l  #0,d3
  157.         bne.s   3$
  158.         btst.l  #1,d3
  159.         bne.s   3$               ;is actual year a leap-year ?
  160.         add.l   #60*60*24,8(a1)  ;feb->29 days !
  161.  
  162. 3$      moveq   #$0,d1
  163. 7$      add.l   (a1)+,d2
  164.         addq    #1,d1
  165.         cmp.b   d0,d1
  166.         bne.s   7$
  167.  
  168.         moveq   #$18,d1
  169.         bsr     getdez
  170. 5$      add.l   #60*60*24,d2
  171.         dbf     d0,5$
  172.         sub.l   #60*60*24*2,d2
  173.  
  174.         moveq   #$10,d1
  175.         bsr     getdez       ;actual hour
  176.         mulu    #60*60,d0
  177.         add.l   d0,d2
  178.  
  179.         moveq   #$8,d1
  180.         bsr     getdez       ;actual minute
  181.         mulu    #60,d0
  182.         add.l   d0,d2
  183.  
  184.         moveq   #0,d1
  185.         bsr     getdez       ;actual second
  186.         add.l   d0,d2
  187.         bra.s   endskip
  188. getdez
  189.         move.l  4(a0,d1.w),d0   ;here we read the hardware clock. Every entry
  190.         and.l   #%1111,d0       ;(year,month,etc.) consists of two 32-bit
  191.         mulu.w  #10,d0          ;registers the first one containing the 2nd
  192.         move.l  0(a0,d1.w),d1   ;digit and the 2nd one containing the 1st digit
  193.         and.l   #%1111,d1       ;(decimal system !!!)
  194.         add.b   d1,d0           ;result -> d0.l
  195.         rts
  196.  
  197. monthtable
  198. tg31    equ     60*60*24*31
  199. tg30    equ     60*60*24*30
  200. tg28    equ     60*60*24*28
  201.         dc.l    0,tg31,tg28,tg31,tg30,tg31,tg30,tg31,tg31,tg30,tg31,tg30
  202.  
  203. endskip
  204.         move.l  d7,a1
  205.         move.l  d2,tv_secs(a1)
  206.         jsr     _lvodoio(a6)   ;now really set the time
  207.         moveq   #60,d0
  208.         bsr     close_a_device ;clean_up
  209.         movem.l (sp)+,d0-7/a0-6
  210.         rts
  211.  
  212. devname
  213.         dc.b    'timer.device',0
  214.         even
  215.  
  216. ;d0=length
  217. ;a0=devname
  218. ;d2=unit
  219. ;d1=flags
  220.  
  221. ;result=d0 0->error ,else pointer to messageport
  222.  
  223. open_a_device
  224.         movem.l d4-d7,-(sp)
  225.         move.l  a0,d4
  226.         move.l  d1,d5
  227.         move.l  d0,d6
  228.         move.l  4.w,a6
  229.         move.l  #$10000,d1
  230.         add.l   #34,d0
  231.         jsr     _lvoallocmem(a6)
  232.         move.l  d0,d7
  233.         beq     od_nomsgmem
  234.         move.l  d0,a0
  235.         moveq   #0,d0
  236.         sub.l   a1,a1
  237.         bsr     createport
  238.         tst.l   d0
  239.         beq     od_noport
  240.         add.l   #34,d7
  241.         move.l  d7,a1
  242.         move.l  a0,mn_replyport(a1)
  243.         move.w  d6,mn_length(a1)
  244.         move.b  #nt_message,ln_type(a1)
  245.         move.l  d2,d0
  246.         move.l  d4,a0
  247.         move.l  d5,d1
  248.         jsr     _lvoopendevice(a6)
  249.         tst.l   d0
  250.         beq.s   od_ok
  251.  
  252. od_error
  253.         move.l  d7,a0
  254.         sub.l   #34,d7
  255.         bsr     deleteport
  256. od_nomsgmem
  257.         moveq   #0,d7
  258. od_ok
  259.         move.l  d7,d0
  260.         movem.l (sp)+,d4-7
  261.         rts
  262.  
  263. od_noport
  264.         move.l  d7,a1
  265.         sub.l   #34,a1
  266.         move.l  d6,d0
  267.         add.l   #34,d0
  268.         jsr     _lvofreemem(a6)
  269.         bra.s   od_nomsgmem
  270.  
  271. ;a1=msgport
  272. ;d0=length
  273.  
  274. close_a_device
  275.         move.l  4.w,a6
  276.         movem.l d0/a1,-(sp)
  277.         jsr     _lvoclosedevice(a6)
  278.         movem.l (sp)+,d0/a1
  279.         move.l  mn_replyport(a1),a0
  280.         bsr     deleteport
  281.         sub.l   #34,a1
  282.         add.l   #34,d0
  283.         jsr     _lvofreemem(a6)
  284.         rts
  285.  
  286.  
  287. ;a0=^to messageport
  288. ;d0= pri
  289. ;a1=^to name
  290. ;this function won't create a public message-port (cause we don't addport
  291. ;our port !)
  292. createport
  293.         move.l  4.w,a6
  294.         move.b  d0,ln_pri(a0)
  295.         move.l  a1,ln_name(a0)
  296.         move.b  #nt_msgport,ln_type(a0)
  297.         move.l  a0,-(sp)
  298.         moveq   #$ff,d0
  299.         jsr     _lvoallocsignal(a6)
  300.         move.l  (sp),a0
  301.         move.b  d0,mp_sigbit(a0)
  302.         addq    #1,d0
  303.         beq.s   cp_error
  304.         sub.l   a1,a1
  305.         jsr     _lvofindtask(a6)
  306.         move.l  (sp)+,a0
  307.         move.l  d0,mp_sigtask(a0)
  308.         moveq   #$ff,d0
  309.         rts
  310. cp_error
  311.         move.l   (sp)+,a0
  312.         moveq    #0,d0
  313.         rts
  314.  
  315.  
  316. ;a0=port
  317.  
  318. deleteport
  319.         movem.l d0/a1,-(sp)
  320.         move.l  4.w,a6
  321.         move.b  #$ff,ln_type(a0)
  322.         moveq   #0,d0
  323.         move.b  mp_sigbit(a0),d0
  324.         jsr     _lvofreesignal(a6)
  325.         movem.l (sp)+,d0/a1
  326.         rts
  327.  
  328.         dc.b    'This programm sets the system-time from your internal clock.'
  329.         dc.b    ' First published on the Fred-Fish collection >540 !!! '
  330.         dc.b    ' Author: Andreas Ackermann, Lorenz-Summa-Str. 10, W-8679 '
  331.         dc.b    ' Oberkotzau   Germany  Phone: 09286/6399 ',0,0
  332.  
  333.         END
  334.  
  335.  
  336. *******************************************************************************
  337. *                                                                             *
  338. *      Enjoy !!!               Another masterpiece of ACKI                    *
  339. *                                                                             *
  340. *******************************************************************************
  341.  
  342.  
  343.  
  344.  
  345.